package com.qdd.freight.handler.impl;

import com.qdd.freight.anno.Mode;
import com.qdd.freight.entity.Datas;
import com.qdd.freight.handler.AbstractHandler;
import com.qdd.freight.pojo.GoodsShip;
import com.qdd.freight.pojo.Ship;
import com.qdd.freight.pojo.YfMode;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 获取快运方式列表modeIdList
 *
 * @ClassName DBHandler
 * @Description TODO
 * @Author yanpeihao
 * @Date 2019/12/6 22:50
 * @Version 3.3
 **/

@Component
@Mode("0")
public class QueryModeHandler extends AbstractHandler {

    /**
     * 继承的方法,不需要使用
     *
     * @return
     */
    @Override
    public String getShipFieldNameFromInstance() {
        return null;
    }

    /**
     * 继承的方法,不需要使用
     *
     * @return
     */
    @Override
    protected Map<String, Object> getAvailableParams(Ship ship, Integer shipId, String consignee) {
        return null;
    }

    /**
     * 实现父类接口方法，编写自有逻辑
     * 获取商品在指定仓库中所支持快运方式编号yf_mode
     *
     * @param goodsShip    商品快运方式对象
     * @param shipId       物流/快递id
     * @param modeId       快运类型
     * @param goodsId      商品id
     * @param entId        仓库id
     * @param quantity     采购数量
     * @param company      企业编号
     * @param consignee    省市区编号
     * @param boxVolume    整箱体积
     * @param singleVolume 单件体积
     * @param boxWeight    整箱重量
     * @param singleWeight 单件重量
     * @param QTYRate      箱规
     * @return
     * @throws Exception
     */
    @Override
    public Datas realHandle(GoodsShip goodsShip, Integer shipId, Integer modeId, Integer goodsId, Integer entId, Integer quantity, Integer company,
                            String consignee, Double boxVolume, Double singleVolume, Double boxWeight,
                            Double singleWeight, Integer QTYRate) throws Exception {
        //获取支持的modeIdList
        List<YfMode> modeList = getModeList(goodsId, entId, quantity);
        //封装peisong数组
        List<Map<String, Object>> peiSong = packagePeiSong(modeList, modeId);
        //封装Datas数据
        Datas datas = new Datas();
        datas.setYf_mode(modeId);
        datas.setPeisong(peiSong);
        return datas;
    }
}